// ex7_13_5.cpp
#include <iostream>

long factorials(long n);
int main(void)
{
    using namespace std;
    long num, resullt;
    
    cout << "Enter a integer: ";

    while ((cin >> num))
    {
        cin.get();
        resullt = factorials(num);
        cout << "factorial of " << num << " is "
            << resullt << endl;
        cout << "Enter a integer: (q to quit)";    
    }
}

long factorials(long n)
{
    if (n >= 0 && n <=1)
        return 1;
    else 
        return n * factorials(n-1);    

}